package cn.myschool.java79.test1;

import cn.myschool.java79.dao.StudentMapper;
import cn.myschool.java79.entity.Student;
import cn.myschool.java79.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class Level2Cache {
    public static void main(String[] args) {
        test1();
        System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
        test1();
       test2();
//        add();
//        System.out.println(">>>>>>>>>>>>>>>新生增加之后：");
//        test1();
    }
    static void test1(){
        SqlSession s= MybatisUtil.get();
        StudentMapper studentMapper=s.getMapper(StudentMapper.class);
        List<Student> list1 = studentMapper.search1("王", "3");
        System.out.println(list1);

        MybatisUtil.close(s);
    }
    static void test2(){
        SqlSession s= MybatisUtil.get();
        StudentMapper studentMapper=s.getMapper(StudentMapper.class);
        List<Student> list1 = studentMapper.search1("李", "3");
        System.out.println(list1);

        MybatisUtil.close(s);
    }
    public static void add(){
        Student st=new Student();
        st.setSname("王桂痕");
        st.setGradeid(5L);
        SqlSession s= MybatisUtil.get();
        StudentMapper studentMapper=s.getMapper(StudentMapper.class);
        studentMapper.add(st);
        MybatisUtil.close(s);
    }

}
